<?php

declare(strict_types=1);

namespace App\Controller;

use App\Service\DemoService;
use Hyperf\Di\Annotation\Inject;

use function Hyperf\Config\config;

class IndexController extends AbstractController
{
    #[Inject]
    protected DemoService $demoService;

    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();

        return [
            'method' => $method,
            'message' => "Hello {$user}.",
            'nacos_config' => config('nacos_config'),
        ];
    }

    public function health()
    {
        return [
            // RPC 调用示例
            'rpc_demo_add' => $this->demoService->testAdd(),
            'rpc_demo_test' => $this->demoService->test(),
        ];
    }
}
